home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume26 / shadow / part10 < prev    next >
Encoding:
Text File  |  1991-11-24  |  54.2 KB  |  2,029 lines

  1. Newsgroups: comp.sources.misc
  2. From: jfh@rpp386.Cactus.ORG (John F Haugh II)
  3. Subject:  v26i063:  shadow - Shadow Password Suite, Part10/11
  4. Message-ID: <1991Nov24.185314.20695@sparky.imd.sterling.com>
  5. X-Md4-Signature: c3fc9042c69b00bfdd627428ac32c0ec
  6. Date: Sun, 24 Nov 1991 18:53:14 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: jfh@rpp386.Cactus.ORG (John F Haugh II)
  10. Posting-number: Volume 26, Issue 63
  11. Archive-name: shadow/part10
  12. Environment: UNIX
  13. Supersedes: shadow-2: Volume 06, Issue 22-24
  14.  
  15. #! /bin/sh
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  19. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  20. # Contents:  chage.1 chpasswd.8 console.c entry.c env.c faillog.8
  21. #   hushed.c login.c mkpasswd.8 newusers.8 passwd.4 port.h porttime.4
  22. #   pwd.h.m4 rad64.c shadow.4 shadow.h sppack.c su.1 sub.c sulogin.8
  23. #   ttytype.c valid.c
  24. # Wrapped by kent@sparky on Sun Nov 24 11:03:44 1991
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. echo If this archive is complete, you will see the following message:
  27. echo '          "shar: End of archive 10 (of 11)."'
  28. if test -f 'chage.1' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'chage.1'\"
  30. else
  31.   echo shar: Extracting \"'chage.1'\" \(1875 characters\)
  32.   sed "s/^X//" >'chage.1' <<'END_OF_FILE'
  33. X.\" Copyright 1990, John F. Haugh II
  34. X.\" All rights reserved.
  35. X.\"
  36. X.\" Use, duplication, and disclosure prohibited without
  37. X.\" the express written permission of the author.
  38. X.\"
  39. X.\"    @(#)chage.1    3.1    09:34:14    11/21/90
  40. X.\"
  41. X.TH CHAGE 1
  42. X.SH NAME
  43. Xchage \- change user password expirate information
  44. X.SH SYNOPSIS
  45. X\fBchage\fR [ \fB-m \fImindays\fR ] [ \fB-M \fImaxdays\fR ] [ \fB-d \fIlastday\fR ] \fIuser\fR
  46. X.SH DESCRIPTION
  47. X\fIchage\f changes the number of days between password changes and the
  48. Xdate of the last password change.
  49. XThis information is used by the system to determine when a user must
  50. Xchange their password.
  51. XThe \fIchage\f command is restricted to the root user.
  52. X.PP
  53. XThe value of \fImindays\f is the minimum number of days between
  54. Xpassword changes.
  55. XA value of zero for this field indicates that the user may change
  56. Xher password at any time.
  57. X.PP
  58. XThe value of \fImaxdays\f is the maximum number of days during
  59. Xwhich a password is valid.
  60. XWhen \fImaxdays\f plus \fIlastday\f is less than the current day,
  61. Xthe user will be required to change her password before being
  62. Xable to use her account.
  63. X.PP
  64. XThe value of \fIlastday\f is the number of days since January 1st,
  65. X1970 when the password was last changed.
  66. X.PP
  67. XAll of the above values are stored exactly as days when the shadow
  68. Xpassword file is used, but are converted to and from weeks when the
  69. Xstandard password file is used.
  70. XBecause of this conversion, rounding errors may result.
  71. X.PP
  72. XIf none of the options are selected, \fIchage\f operates in an interactive
  73. Xfashion, prompting the user with the current values for all of the fields.
  74. XEnter the new value to change the field, or leave the line blank to use
  75. Xthe current value.
  76. XThe current value is displayed between a pair of \fB[ ]\f marks.
  77. X.SH Files
  78. X/etc/passwd \- user account information
  79. X.br
  80. X/etc/shadow \- shadow user account information
  81. X.SH See Also
  82. Xpasswd(4),
  83. Xshadow(4)
  84. END_OF_FILE
  85.   if test 1875 -ne `wc -c <'chage.1'`; then
  86.     echo shar: \"'chage.1'\" unpacked with wrong size!
  87.   fi
  88.   # end of 'chage.1'
  89. fi
  90. if test -f 'chpasswd.8' -a "${1}" != "-c" ; then 
  91.   echo shar: Will not clobber existing file \"'chpasswd.8'\"
  92. else
  93.   echo shar: Extracting \"'chpasswd.8'\" \(1268 characters\)
  94.   sed "s/^X//" >'chpasswd.8' <<'END_OF_FILE'
  95. X.\" Copyright 1991, John F. Haugh II
  96. X.\" All rights reserved.
  97. X.\"
  98. X.\" Permission is granted to copy and create derivative works for any
  99. X.\" non-commercial purpose, provided this copyright notice is preserved
  100. X.\" in all copies of source code, or included in human readable form
  101. X.\" and conspicuously displayed on all copies of object code or
  102. X.\" distribution media.
  103. X.\"
  104. X.\"    @(#)chpasswd.8    3.1    16:50:16    8/4/91
  105. X.\"
  106. X.TH CHPASSWD 8
  107. X.SH NAME
  108. X\fBchpasswd\fR - update password file in batch
  109. X.SH SYNOPSIS
  110. X\fBchpasswd\fR
  111. X.SH DESCRIPTION
  112. X\fBchpasswd\fR reads a file of user name and cleartext password pairs
  113. Xfrom standard input and uses this information
  114. Xto update a group of existing users.
  115. XEach line is of the format
  116. X.DS
  117. X      \fIuser_name\fR:\fIpassword\fR
  118. X.DE
  119. XThe named user must exist.
  120. XThe supplied password will be encrypted and the password age updated,
  121. Xif present.
  122. X.PP
  123. XThis command is intended to be used in a large system environment where
  124. Xmany accounts are created at a single time.
  125. X.SH CAVEATS
  126. XThe \fImkpasswd\fR command must be executed afterwards to update the
  127. XDBM password files.
  128. XThe input file must be protected since it contains unencrypted passwords.
  129. XThis command may be discarded in favor of the newusers(8) command.
  130. X.SH SEE ALSO
  131. Xmkpasswd(8), passwd(1), useradd(1)
  132. END_OF_FILE
  133.   if test 1268 -ne `wc -c <'chpasswd.8'`; then
  134.     echo shar: \"'chpasswd.8'\" unpacked with wrong size!
  135.   fi
  136.   # end of 'chpasswd.8'
  137. fi
  138. if test -f 'console.c' -a "${1}" != "-c" ; then 
  139.   echo shar: Will not clobber existing file \"'console.c'\"
  140. else
  141.   echo shar: Extracting \"'console.c'\" \(2025 characters\)
  142.   sed "s/^X//" >'console.c' <<'END_OF_FILE'
  143. X/*
  144. X * Copyright 1991, John F. Haugh II and Chip Rosenthal
  145. X * All rights reserved.
  146. X *
  147. X * Permission is granted to copy and create derivative works for any
  148. X * non-commercial purpose, provided this copyright notice is preserved
  149. X * in all copies of source code, or included in human readable form
  150. X * and conspicuously displayed on all copies of object code or
  151. X * distribution media.
  152. X */
  153. X
  154. X#ifndef lint
  155. Xstatic    char    sccsid[] = "@(#)console.c    3.1    07:47:49    9/17/91";
  156. X#endif
  157. X
  158. X#include <stdio.h>
  159. X#ifndef BSD
  160. X# include <string.h>
  161. X#else
  162. X# include <strings.h>
  163. X#endif
  164. X
  165. Xextern    char    *getdef_str();
  166. X
  167. X/*
  168. X * tty - return 1 if the "tty" is a console device, else 0.
  169. X *
  170. X * Note - we need to take extreme care here to avoid locking out root logins
  171. X * if something goes awry.  That's why we do things like call everything a
  172. X * console if the consoles file can't be opened.  Because of this, we must
  173. X * warn the user to protect against the remove of the consoles file since
  174. X * that would allow an unauthorized root login.
  175. X */
  176. X
  177. Xint
  178. Xconsole (tty)
  179. Xchar    *tty;
  180. X{
  181. X    FILE    *fp;
  182. X    char    buf[BUFSIZ], *console, *s;
  183. X
  184. X    /*
  185. X     * If the CONSOLE configuration definition isn't given, call
  186. X     * everything a valid console.
  187. X     */
  188. X
  189. X    if ((console = getdef_str("CONSOLE")) == NULL)
  190. X        return 1;
  191. X
  192. X    /*
  193. X     * If this isn't a filename, then it is a ":" delimited list of
  194. X     * console devices upon which root logins are allowed.
  195. X     */
  196. X
  197. X    if (*console != '/') {
  198. X        console = strcpy(buf,console);
  199. X        while ((s = strtok(console,":")) != NULL) {
  200. X            if (strcmp(s,tty) == 0)
  201. X                return 1;
  202. X
  203. X            console = NULL;
  204. X        }
  205. X        return 0;
  206. X    }
  207. X
  208. X    /*
  209. X     * If we can't open the console list, then call everything a
  210. X     * console - otherwise root will never be allowed to login.
  211. X     */
  212. X
  213. X    if ((fp = fopen(console,"r")) == NULL)
  214. X        return 1;
  215. X
  216. X    /*
  217. X     * See if this tty is listed in the console file.
  218. X     */
  219. X
  220. X    while (fgets(buf,sizeof(buf),fp) != NULL) {
  221. X        buf[strlen(buf)-1] = '\0';
  222. X        if (strcmp(buf,tty) == 0) {
  223. X            (void) fclose(fp);
  224. X            return 1;
  225. X        }
  226. X    }
  227. X
  228. X    /*
  229. X     * This tty isn't a console.
  230. X     */
  231. X
  232. X    (void) fclose(fp);
  233. X    return 0;
  234. X}
  235. END_OF_FILE
  236.   if test 2025 -ne `wc -c <'console.c'`; then
  237.     echo shar: \"'console.c'\" unpacked with wrong size!
  238.   fi
  239.   # end of 'console.c'
  240. fi
  241. if test -f 'entry.c' -a "${1}" != "-c" ; then 
  242.   echo shar: Will not clobber existing file \"'entry.c'\"
  243. else
  244.   echo shar: Extracting \"'entry.c'\" \(1994 characters\)
  245.   sed "s/^X//" >'entry.c' <<'END_OF_FILE'
  246. X/*
  247. X * Copyright 1989, 1990, 1991, John F. Haugh II
  248. X * All rights reserved.
  249. X *
  250. X * Permission is granted to copy and create derivative works for any
  251. X * non-commercial purpose, provided this copyright notice is preserved
  252. X * in all copies of source code, or included in human readable form
  253. X * and conspicuously displayed on all copies of object code or
  254. X * distribution media.
  255. X */
  256. X
  257. X#include "pwd.h"
  258. X#ifndef    BSD
  259. X#include <string.h>
  260. X#else
  261. X#include <strings.h>
  262. X#define    strchr    index
  263. X#define    strrchr    rindex
  264. X#endif
  265. X#include "config.h"
  266. X#ifdef    SHADOWPWD
  267. X#include "shadow.h"
  268. X#endif
  269. X
  270. X#ifndef    lint
  271. Xstatic    char    sccsid[] = "@(#)entry.c    3.4    08:57:50    7/10/91";
  272. X#endif
  273. X
  274. Xstruct    passwd    *fgetpwent ();
  275. Xchar    *malloc ();
  276. X
  277. Xvoid    entry (name, pwent)
  278. Xchar    *name;
  279. Xstruct    passwd    *pwent;
  280. X{
  281. X    struct    passwd    *passwd;
  282. X#ifdef    SHADOWPWD
  283. X    struct    spwd    *spwd;
  284. X    char    *l64a ();
  285. X#endif
  286. X    char    *cp;
  287. X    char    *malloc();
  288. X
  289. X    if (! (passwd = getpwnam (name))) {
  290. X        pwent->pw_name = (char *) 0;
  291. X        return;
  292. X    } else  {
  293. X        pwent->pw_name = strdup (passwd->pw_name);
  294. X        pwent->pw_uid = passwd->pw_uid;
  295. X        pwent->pw_gid = passwd->pw_gid;
  296. X#ifdef    ATT_COMMENT
  297. X        pwent->pw_comment = strdup (passwd->pw_comment);
  298. X#endif
  299. X        pwent->pw_gecos = strdup (passwd->pw_gecos);
  300. X        pwent->pw_dir = strdup (passwd->pw_dir);
  301. X        pwent->pw_shell = strdup (passwd->pw_shell);
  302. X#if defined(SHADOWPWD) && !defined(AUTOSHADOW)
  303. X        setspent ();
  304. X        if (spwd = getspnam (name)) {
  305. X            pwent->pw_passwd = strdup (spwd->sp_pwdp);
  306. X#ifdef    ATT_AGE
  307. X            pwent->pw_age = (char *) malloc (5);
  308. X
  309. X            if (spwd->sp_max > (63*7))
  310. X                spwd->sp_max = (63*7);
  311. X            if (spwd->sp_min > (63*7))
  312. X                spwd->sp_min = (63*7);
  313. X
  314. X            pwent->pw_age[0] = i64c (spwd->sp_max / 7);
  315. X            pwent->pw_age[1] = i64c (spwd->sp_min / 7);
  316. X
  317. X            cp = l64a (spwd->sp_lstchg / 7);
  318. X            pwent->pw_age[2] = cp[0];
  319. X            pwent->pw_age[3] = cp[1];
  320. X
  321. X            pwent->pw_age[4] = '\0';
  322. X#endif
  323. X            endspent ();
  324. X            return;
  325. X        }
  326. X        endspent ();
  327. X#endif
  328. X        pwent->pw_passwd = strdup (passwd->pw_passwd);
  329. X#ifdef    ATT_AGE
  330. X        pwent->pw_age = strdup (passwd->pw_age);
  331. X#endif
  332. X    }
  333. X}
  334. END_OF_FILE
  335.   if test 1994 -ne `wc -c <'entry.c'`; then
  336.     echo shar: \"'entry.c'\" unpacked with wrong size!
  337.   fi
  338.   # end of 'entry.c'
  339. fi
  340. if test -f 'env.c' -a "${1}" != "-c" ; then 
  341.   echo shar: Will not clobber existing file \"'env.c'\"
  342. else
  343.   echo shar: Extracting \"'env.c'\" \(1788 characters\)
  344.   sed "s/^X//" >'env.c' <<'END_OF_FILE'
  345. X/*
  346. X * Copyright 1989, 1990, John F. Haugh II
  347. X * All rights reserved.
  348. X *
  349. X * Use, duplication, and disclosure prohibited without
  350. X * the express written permission of the author.
  351. X */
  352. X
  353. X#include <stdio.h>
  354. X#ifndef    BSD
  355. X#include <string.h>
  356. X#else
  357. X#define    strchr    index
  358. X#define    strrchr    rindex
  359. X#include <strings.h>
  360. X#endif
  361. X
  362. X#ifndef    lint
  363. Xstatic    char    _sccsid[] = "@(#)env.c    2.2    19:23:43    7/29/90";
  364. X#endif
  365. X
  366. Xextern    char    **environ;
  367. Xextern    char    *newenvp[];
  368. Xextern    int    newenvc;
  369. Xextern    int    maxenv;
  370. X
  371. Xchar    *strdup ();
  372. Xvoid    free ();
  373. X
  374. Xstatic    char    *forbid[] = {
  375. X    "HOME",
  376. X    "IFS",
  377. X    "PATH",
  378. X    "SHELL",
  379. X    (char *) 0
  380. X};
  381. X
  382. Xvoid    addenv (entry)
  383. Xchar    *entry;
  384. X{
  385. X    char    *cp;
  386. X    int    i;
  387. X    int    len;
  388. X
  389. X    if (cp = strchr (entry, '='))
  390. X        len = cp - entry;
  391. X    else
  392. X        return;
  393. X
  394. X    for (i = 0;i < newenvc;i++)
  395. X        if (strncmp (entry, newenvp[i], len) == 0 &&
  396. X            (newenvp[i][len] == '=' || newenvp[i][len] == '\0'))
  397. X            break;
  398. X
  399. X    if (i == maxenv) {
  400. X        puts ("Environment overflow");
  401. X        return;
  402. X    }
  403. X    if (i == newenvc) {
  404. X        newenvp[newenvc++] = strdup (entry);
  405. X    } else {
  406. X        free (newenvp[i]);
  407. X        newenvp[i] = strdup (entry);
  408. X    }
  409. X}
  410. X
  411. Xvoid    setenv (argc, argv)
  412. Xint    argc;
  413. Xchar    **argv;
  414. X{
  415. X    int    i;
  416. X    int    n;
  417. X    int    noname = 1;
  418. X    char    variable[BUFSIZ];
  419. X    char    *cp;
  420. X
  421. X    for (i = 0;i < argc;i++) {
  422. X        if ((n = strlen (argv[i])) >= BUFSIZ)
  423. X            continue;    /* ignore long entries */
  424. X
  425. X        if (! (cp = strchr (argv[i], '='))) {
  426. X            (void) strcpy (variable, argv[i]);
  427. X        } else {
  428. X            (void) strncpy (variable, argv[i], cp - argv[i]);
  429. X            variable[cp - argv[i]] = '\0';
  430. X        }
  431. X        for (n = 0;forbid[n] != (char *) 0;n++)
  432. X            if (strcmp (variable, forbid[n]) == 0)
  433. X                break;
  434. X
  435. X        if (forbid[n] != (char *) 0) {
  436. X            printf ("You may not change $%s\n", forbid[n]);
  437. X            continue;
  438. X        }
  439. X        if (cp) {
  440. X            addenv (argv[i]);
  441. X        } else {
  442. X            sprintf (variable, "L%d=%s", noname++, argv[i]);
  443. X            addenv (variable);
  444. X        }
  445. X    }
  446. X}
  447. END_OF_FILE
  448.   if test 1788 -ne `wc -c <'env.c'`; then
  449.     echo shar: \"'env.c'\" unpacked with wrong size!
  450.   fi
  451.   # end of 'env.c'
  452. fi
  453. if test -f 'faillog.8' -a "${1}" != "-c" ; then 
  454.   echo shar: Will not clobber existing file \"'faillog.8'\"
  455. else
  456.   echo shar: Extracting \"'faillog.8'\" \(2030 characters\)
  457.   sed "s/^X//" >'faillog.8' <<'END_OF_FILE'
  458. X.\" Copyright 1989, 1990, John F. Haugh II
  459. X.\" All rights reserved.
  460. X.\"
  461. X.\" Use, duplication, and disclosure prohibited without
  462. X.\" the express written permission of the author.
  463. X.\"
  464. X.\"    @(#)faillog.8    3.1    09:34:20    11/21/90
  465. X.\"
  466. X.TH FAILLOG 8
  467. X.SH NAME
  468. Xfaillog \- examine faillog and set login failure limits
  469. X.SH SYNOPSIS
  470. X/etc/faillog [ -u uid ] [ -t days ] [ -m max ] [ -pr ] 
  471. X.SH DESCRIPTION
  472. X\fIPlastlog\fR formats the contents of the failure log,
  473. X\fI/usr/adm/faillog\fR, and maintains failure counts and
  474. Xlimits.
  475. XThe order of the arguments to \fIfaillog\fR is significant.
  476. XEach argument is processed immediately in the order given.
  477. X.PP
  478. XThe \fB-p\fR flag causes failure entries to be printed in UID
  479. Xorder.
  480. XEntering \fB-u login-name\fR flag will
  481. Xcause the failure record for \fBlogin-name\fR only to be printed.
  482. XEntering \fB-t days\fR will cause only the
  483. Xfailures more recent than \fBdays\fR to be printed.
  484. XThe \fB-t\fR flag overrides the use of \fB-u\fR.
  485. X.PP
  486. XThe \fB-r\fR flag is used to reset the count of login failures.
  487. XWrite access to \fI/usr/adm/faillog\fR is required for
  488. Xthis option.
  489. XEntering \fB-u login-name\fR will cause only the failure count
  490. Xfor \fBlogin-name\fR to be reset.
  491. X.PP
  492. XThe \fB-m\fR flag is used to set the maximum number of login
  493. Xfailures before the account is disabled.
  494. XWrite access to \fB/usr/adm/faillog\fR is required for this
  495. Xoption.
  496. XEntering \fB-m max\fR will cause all accounts to be disabled
  497. Xafter \fBmax\fR failed logins occur.
  498. XThis may be modified with \fB-u login-name\fR to limit this
  499. Xfunction to \fBlogin-name\fR only.
  500. XSelecting a \fBmax\fR value of 0 has the effect of not placing
  501. Xa limit on the number of failed logins.
  502. XThe maximum failure count
  503. Xshould always be 0 for \fBroot\fR to prevent
  504. Xa denial of services attack against the system.
  505. X.PP
  506. XOptions may be combined in virtually any fashion.
  507. XEach \fB-p\fR, \fB-r\fR, and \fB-m\fR option will cause
  508. Ximmediate execution using any \fB-u\fR or \fB-t\fR modifier.
  509. X.SH Files
  510. X/usr/adm/faillog \- failure logging file
  511. X.SH See Also
  512. Xlogin(1),
  513. Xfaillog(4)
  514. END_OF_FILE
  515.   if test 2030 -ne `wc -c <'faillog.8'`; then
  516.     echo shar: \"'faillog.8'\" unpacked with wrong size!
  517.   fi
  518.   # end of 'faillog.8'
  519. fi
  520. if test -f 'hushed.c' -a "${1}" != "-c" ; then 
  521.   echo shar: Will not clobber existing file \"'hushed.c'\"
  522. else
  523.   echo shar: Extracting \"'hushed.c'\" \(1678 characters\)
  524.   sed "s/^X//" >'hushed.c' <<'END_OF_FILE'
  525. X/*
  526. X * Copyright 1991, John F. Haugh II and Chip Rosenthal
  527. X * All rights reserved.
  528. X *
  529. X * Permission is granted to copy and create derivative works for any
  530. X * non-commercial purpose, provided this copyright notice is preserved
  531. X * in all copies of source code, or included in human readable form
  532. X * and conspicuously displayed on all copies of object code or
  533. X * distribution media.
  534. X */
  535. X
  536. X#ifndef lint
  537. Xstatic    char    sccsid[] = "@(#)hushed.c    3.1    07:47:53    9/17/91";
  538. X#endif
  539. X
  540. X#include <stdio.h>
  541. X#ifndef BSD
  542. X# include <string.h>
  543. X#else
  544. X# include <strings.h>
  545. X#endif
  546. X#include "config.h"
  547. X#include "pwd.h"
  548. X
  549. Xextern char *getdef_str();
  550. X
  551. X/*
  552. X * hushed - determine if a user receives login messages
  553. X *
  554. X * Look in the hushed-logins file (or user's home directory) to see
  555. X * if the user is to receive the login-time messages.
  556. X */
  557. X
  558. Xint
  559. Xhushed(pw)
  560. Xstruct passwd *pw;
  561. X{
  562. X    char *hushfile;
  563. X    char buf[BUFSIZ];
  564. X    int found;
  565. X    FILE *fp;
  566. X
  567. X    /*
  568. X     * Get the name of the file to use.  If this option is not
  569. X     * defined, default to a noisy login.
  570. X     */
  571. X
  572. X    if ( (hushfile=getdef_str("HUSHLOGIN_FILE")) == NULL )
  573. X        return 0;
  574. X
  575. X    /*
  576. X     * If this is not a fully rooted path then see if the
  577. X     * file exists in the user's home directory.
  578. X     */
  579. X
  580. X    if (hushfile[0] != '/') {
  581. X        strcat(strcat(strcpy(buf, pw->pw_dir), "/"), hushfile);
  582. X        return (access(buf, 0) == 0);
  583. X    }
  584. X
  585. X    /*
  586. X     * If this is a fully rooted path then go through the file
  587. X     * and see if this user is in there.
  588. X     */
  589. X
  590. X    if ((fp = fopen(hushfile, "r")) == NULL)
  591. X        return 0;
  592. X
  593. X    for (found = 0;! found && fgets (buf, sizeof buf, fp);) {
  594. X        buf[strlen (buf) - 1] = '\0';
  595. X        found = ! strcmp (buf,
  596. X            buf[0] == '/' ? pw->pw_shell:pw->pw_name);
  597. X    }
  598. X    (void) fclose(fp);
  599. X    return found;
  600. X}
  601. END_OF_FILE
  602.   if test 1678 -ne `wc -c <'hushed.c'`; then
  603.     echo shar: \"'hushed.c'\" unpacked with wrong size!
  604.   fi
  605.   # end of 'hushed.c'
  606. fi
  607. if test -f 'login.c' -a "${1}" != "-c" ; then 
  608.   echo shar: Will not clobber existing file \"'login.c'\"
  609. else
  610.   echo shar: Extracting \"'login.c'\" \(1840 characters\)
  611.   sed "s/^X//" >'login.c' <<'END_OF_FILE'
  612. X/*
  613. X * Copyright 1989, 1990, 1991, John F. Haugh II
  614. X * All rights reserved.
  615. X *
  616. X * Permission is granted to copy and create derivative works for any
  617. X * non-commercial purpose, provided this copyright notice is preserved
  618. X * in all copies of source code, or included in human readable form
  619. X * and conspicuously displayed on all copies of object code or
  620. X * distribution media.
  621. X */
  622. X
  623. X#include <stdio.h>
  624. X#include <ctype.h>
  625. X#ifndef    BSD
  626. X#include <string.h>
  627. X#include <memory.h>
  628. X#else
  629. X#include <strings.h>
  630. X#define    strchr    index
  631. X#define    strrchr    rindex
  632. X#endif
  633. X
  634. X#ifndef    lint
  635. Xstatic    char    sccsid[] = "@(#)login.c    3.1    20:54:10    9/18/91";
  636. X#endif
  637. X
  638. Xvoid    setenv ();
  639. X
  640. X/*
  641. X * login - prompt the user for their login name
  642. X *
  643. X * login() displays the standard login prompt.  If the option
  644. X * ISSUE_FILE_ENAB is set, the file /etc/issue is displayed
  645. X * before the prompt.
  646. X */
  647. X
  648. Xvoid
  649. Xlogin (name)
  650. Xchar    *name;
  651. X{
  652. X    char    buf[BUFSIZ];
  653. X    char    *envp[32];
  654. X    int    envc;
  655. X    char    *cp;
  656. X    int    i;
  657. X    FILE    *fp;
  658. X
  659. X    /*
  660. X     * See if the user has configured the /etc/issue file to
  661. X     * be displayed.
  662. X     */
  663. X
  664. X    if (getdef_bool ("ISSUE_FILE_ENAB")) {
  665. X        if (fp = fopen ("/etc/issue", "r")) {
  666. X            while ((i = getc (fp)) != EOF)
  667. X                putc (i, stdout);
  668. X
  669. X            fflush (stdout);
  670. X            fclose (fp);
  671. X        }
  672. X    }
  673. X#ifndef    BSD
  674. X    (void) memset (buf, '\0', sizeof buf);
  675. X#else
  676. X    bzero (buf, sizeof buf);
  677. X#endif
  678. X    fputs ("login: ", stdout);
  679. X
  680. X    if (fgets (buf, BUFSIZ, stdin) != buf)
  681. X        exit (1);
  682. X
  683. X    buf[strlen (buf) - 1] = '\0';    /* remove \n [ must be there ] */
  684. X
  685. X    for (cp = buf;*cp == ' ' || *cp == '\t';cp++)
  686. X        ;
  687. X
  688. X    for (i = 0;i < BUFSIZ - 1 && isgraph (*cp);name[i++] = *cp++)
  689. X        ;
  690. X
  691. X    if (*cp)
  692. X        cp++;
  693. X
  694. X    name[i] = '\0';
  695. X
  696. X    if (*cp != '\0') {        /* process new variables */
  697. X        for (envc = 0;envc < 32;envc++) {
  698. X            envp[envc] = strtok (envc == 0 ? cp:(char *) 0, " \t,");
  699. X
  700. X            if (envp[envc] == (char *) 0)
  701. X                break;
  702. X        }
  703. X        setenv (envc, envp);
  704. X    }
  705. X}
  706. END_OF_FILE
  707.   if test 1840 -ne `wc -c <'login.c'`; then
  708.     echo shar: \"'login.c'\" unpacked with wrong size!
  709.   fi
  710.   # end of 'login.c'
  711. fi
  712. if test -f 'mkpasswd.8' -a "${1}" != "-c" ; then 
  713.   echo shar: Will not clobber existing file \"'mkpasswd.8'\"
  714. else
  715.   echo shar: Extracting \"'mkpasswd.8'\" \(2125 characters\)
  716.   sed "s/^X//" >'mkpasswd.8' <<'END_OF_FILE'
  717. X.\" Copyright 1991, John F. Haugh II
  718. X.\" All rights reserved.
  719. X.\"
  720. X.\" Permission is granted to copy and create derivative works for any
  721. X.\" non-commercial purpose, provided this copyright notice is preserved
  722. X.\" in all copies of source code, or included in human readable form
  723. X.\" and conspicuously displayed on all copies of object code or
  724. X.\" distribution media.
  725. X.\"
  726. X.\"    @(#)mkpasswd.8    3.1    07:49:05    7/13/91
  727. X.\"
  728. X.TH MKPASSWD 1
  729. X.SH NAME
  730. Xmkpasswd \- Update passwd and group database files
  731. X.SH SYNOPSIS
  732. X\fBmkpasswd\fR [ \fB-fvgps\fR ] \fIfile\fR
  733. X.SH DESCRIPTION
  734. X.I mkpasswd
  735. Xreads the file in the format given by the flags and converts it to the
  736. Xcorresponding database file format.
  737. XThese database files are used to improve access performance on systems
  738. Xwith large numbers of users.
  739. XThe output files will be named \fIfile\fR.dir and \fIfile\fR.pag.
  740. X.PP
  741. XThe \fB-f\fR option causes \fImkpasswd\fR to ignore any existing output
  742. Xfiles and overwrite them.
  743. XNormally \fImkpasswd\fR complains about existing output files and quits.
  744. X.PP
  745. XThe \fB-v\fR option causes \fImkpasswd\fR to output information about
  746. Xeach record as it is converted, with a final message at the very end.
  747. X.PP
  748. XThe \fB-g\fR option treats the input file as though it were in
  749. X\fB/etc/group\fR file format.
  750. XWhen combined with the \fB-s\fR option, the \fB/etc/gshadow\fR file
  751. Xformat is used instead.
  752. X.PP
  753. XThe \fB-p\fR option treats the input file as though it were in
  754. X\fB/etc/passwd\fR file format.
  755. XThis is the default.
  756. XWhen combined with the \fB-s\fR option, the \fB/etc/shadow\fR file
  757. Xformat is used instead.
  758. X.SH CAVEATS
  759. XThe use of more than one database file is limited to systems which
  760. Xinclude the NDBM database library and therefore may not be available
  761. Xon every system.
  762. X.SH Note
  763. XSince most commands are capable of updating the database files as
  764. Xchanges are made, this command need only be used when re-creating a
  765. Xdeleted or corrupted database file.
  766. X.SH Files
  767. X/etc/passwd \- user account information
  768. X.br
  769. X/etc/shadow \- shadow user information
  770. X.br
  771. X/etc/group \- group information
  772. X.br
  773. X/etc/gshadow \- shadow group information
  774. X.SH See Also
  775. Xpasswd(4), group(4), shadow(4)
  776. END_OF_FILE
  777.   if test 2125 -ne `wc -c <'mkpasswd.8'`; then
  778.     echo shar: \"'mkpasswd.8'\" unpacked with wrong size!
  779.   fi
  780.   # end of 'mkpasswd.8'
  781. fi
  782. if test -f 'newusers.8' -a "${1}" != "-c" ; then 
  783.   echo shar: Will not clobber existing file \"'newusers.8'\"
  784. else
  785.   echo shar: Extracting \"'newusers.8'\" \(1805 characters\)
  786.   sed "s/^X//" >'newusers.8' <<'END_OF_FILE'
  787. X.\" Copyright 1991, John F. Haugh II
  788. X.\" All rights reserved.
  789. X.\"
  790. X.\" Permission is granted to copy and create derivative works for any
  791. X.\" non-commercial purpose, provided this copyright notice is preserved
  792. X.\" in all copies of source code, or included in human readable form
  793. X.\" and conspicuously displayed on all copies of object code or
  794. X.\" distribution media.
  795. X.\"
  796. X.\"    @(#)newusers.8    3.1    16:49:47    8/4/91
  797. X.\"
  798. X.TH NEWUSERS 8
  799. X.SH NAME
  800. X\fBnewusers\fR - update and create new users in batch
  801. X.SH SYNOPSIS
  802. X\fBnewusers\fR
  803. X[ \fI new_users \fR ]
  804. X.SH DESCRIPTION
  805. X\fBnewusers\fR reads a file of user name and cleartext password pairs
  806. Xand uses this information to update a group of existing users or to
  807. Xcreate new users.
  808. XEach line is in the same format as the standard password file (see
  809. X\fIpasswd(4)\fR) with the following exceptions.
  810. X.IP "pw_passwd"
  811. XThis field will be encrypted and used as the new value
  812. Xof the encrpted password.
  813. X.IP "pw_age"
  814. XThis field will be ignored for shadow passwords if the user already
  815. Xexists.
  816. X.IP "pw_gid"
  817. XThis field may be the name of an existing group, in which case the
  818. Xnamed user will be added as a member.  If a non-existent numerical
  819. Xgroup is given, a new group will be created having this number.
  820. X.IP "pw_dir"
  821. XThis field will be checked for existence as a directory and a new
  822. Xdirectory will the same name created if it does not already exist.
  823. XThe ownership of the directory will be set to be that of the user
  824. Xbeing created or updated.
  825. X.PP
  826. XThis command is intended to be used in a large system environment where
  827. Xmany accounts are updated at a single time.
  828. X.SH CAVEATS
  829. XThe \fImkpasswd\fR command must be executed afterwards to update the
  830. XDBM password files.
  831. XThe input file must be protected since it contains unencrypted passwords.
  832. X.SH SEE ALSO
  833. Xmkpasswd(8), passwd(1), useradd(1)
  834. END_OF_FILE
  835.   if test 1805 -ne `wc -c <'newusers.8'`; then
  836.     echo shar: \"'newusers.8'\" unpacked with wrong size!
  837.   fi
  838.   # end of 'newusers.8'
  839. fi
  840. if test -f 'passwd.4' -a "${1}" != "-c" ; then 
  841.   echo shar: Will not clobber existing file \"'passwd.4'\"
  842. else
  843.   echo shar: Extracting \"'passwd.4'\" \(2520 characters\)
  844.   sed "s/^X//" >'passwd.4' <<'END_OF_FILE'
  845. X.\" Copyright 1989, 1990, John F. Haugh II
  846. X.\" All rights reserved.
  847. X.\"
  848. X.\" Use, duplication, and disclosure prohibited without
  849. X.\" the express written permission of the author.
  850. X.\"
  851. X.\"    @(#)passwd.4    3.1    09:34:24    11/21/90
  852. X.\"
  853. X.TH PASSWD 4
  854. X.SH NAME
  855. Xpasswd \- The password file
  856. X.SH DESCRIPTION
  857. X.I passwd
  858. Xcontains various pieces of information for each user account.
  859. XIncluded is
  860. X.IP "" .5i
  861. XLogin name
  862. X.IP "" .5i
  863. XOptional encrypted password
  864. X.IP "" .5i
  865. XNumerical user ID
  866. X.IP "" .5i
  867. XNumerical group ID
  868. X.IP "" .5i
  869. XUser name or comment field
  870. X.IP "" .5i
  871. XUser home directory
  872. X.IP "" .5i
  873. XUser command interpreter
  874. X.PP
  875. XThe password field may not be filled if shadow passwords
  876. Xhave been enabled.
  877. XIf shadow passwords are being used, the encrypted password will
  878. Xbe found in \fB/etc/shadow\fR.
  879. XThe encryped password consists of 13 characters from the
  880. X64 character alphabet
  881. Xa thru z, A thru Z, 0 thru 9, \. and /.
  882. XRefer to \fIcrypt(3)\fR for details on how this string is
  883. Xinterpreted.
  884. X.PP
  885. XAn optional password age string may follow the encrypted
  886. Xpassword, separated by a comma, from the same alphabet
  887. Xas the password itself.
  888. XThe first character gives the number of weeks during which the
  889. Xpassword is valid.
  890. XThe second character gives the number of weeks which must pass
  891. Xbefore the user is permitted to change the password.
  892. XThe last two characters give the week since Jan 1970 when the
  893. Xpassword was last changed.
  894. XWhen the number of weeks during which the password is valid
  895. Xhave passed, the user will be required to provide a new
  896. Xpassword.
  897. X.PP
  898. XThe comment field is used by various system utilities, such as
  899. X\fIfinger(1)\fR.
  900. XThree additional values may be present in the comment field.
  901. XThey are
  902. X.IP "" .5i
  903. Xpri= \- set initial value of nice
  904. X.IP "" .5i
  905. Xumask= \- set initial value of umask
  906. X.IP "" .5i
  907. Xulimit= \- set initial value of ulimit
  908. X.PP
  909. XThese fields are separated from each other and from any other
  910. Xcomment field by a comma.
  911. X.PP
  912. XThe home directory field provides the name of the initial
  913. Xworking directory.
  914. X\fILogin\fR uses this information to set the value of
  915. Xthe \fBHOME\fR environmental variable.
  916. X.PP
  917. XThe command interpreter field provides the name of the user's
  918. Xcommand language interpreter, or the name of the initial program
  919. Xto execute.
  920. X\fILogin\fR uses this information to set the value of the
  921. X\fBSHELL\fR environmental variable.
  922. XIf this field is empty, it defaults to the value \fB/bin/sh\fR.
  923. X.SH Files
  924. X/etc/passwd \- user account information
  925. X.SH See Also
  926. Xlogin(1),
  927. Xpasswd(1),
  928. Xsu(1),
  929. Xsulogin(1M),
  930. Xshadow(4),
  931. Xpwconv(8),
  932. Xpwunconv(8)
  933. END_OF_FILE
  934.   if test 2520 -ne `wc -c <'passwd.4'`; then
  935.     echo shar: \"'passwd.4'\" unpacked with wrong size!
  936.   fi
  937.   # end of 'passwd.4'
  938. fi
  939. if test -f 'port.h' -a "${1}" != "-c" ; then 
  940.   echo shar: Will not clobber existing file \"'port.h'\"
  941. else
  942.   echo shar: Extracting \"'port.h'\" \(1743 characters\)
  943.   sed "s/^X//" >'port.h' <<'END_OF_FILE'
  944. X/*
  945. X * Copyright 1989, 1990, 1991, John F. Haugh II
  946. X * All rights reserved.
  947. X *
  948. X * Permission is granted to copy and create derivative works for any
  949. X * non-commercial purpose, provided this copyright notice is preserved
  950. X * in all copies of source code, or included in human readable form
  951. X * and conspicuously displayed on all copies of object code or
  952. X * distribution media.
  953. X */
  954. X
  955. X/*
  956. X * port.h - structure of /etc/porttime
  957. X *
  958. X *    @(#)port.h    3.1    08:59:36    2/8/91
  959. X *
  960. X *    Each entry in /etc/porttime consists of a TTY device
  961. X *    name or "*" to indicate all TTY devices, followed by
  962. X *    a list of 1 or more user IDs or "*" to indicate all
  963. X *    user names, followed by a list of zero or more valid
  964. X *    login times.  Login time entries consist of zero or
  965. X *    more day names (Su, Mo, Tu, We, Th, Fr, Sa, Wk, Al)
  966. X *    followed by a pair of time values in HHMM format
  967. X *    separated by a "-".
  968. X */
  969. X
  970. X/*
  971. X * PORTS - Name of system port access time file.
  972. X * PORT_IDS - Allowable number of IDs per entry.
  973. X * PORT_TTY - Allowable number of TTYs per entry.
  974. X * PORT_TIMES - Allowable number of time entries per entry.
  975. X * PORT_DAY - Day of the week to a bit value (0 = Sunday).
  976. X */
  977. X
  978. X#define    PORTS    "/etc/porttime"
  979. X#define    PORT_IDS    64
  980. X#define    PORT_TTY    64
  981. X#define    PORT_TIMES    24
  982. X#define    PORT_DAY(day)    (1<<(day))
  983. X
  984. X/*
  985. X *    pt_names - pointer to array of device names in /dev/
  986. X *    pt_users - pointer to array of applicable user IDs.
  987. X *    pt_times - pointer to list of allowable time periods.
  988. X */
  989. X
  990. Xstruct    port    {
  991. X    char    **pt_names;
  992. X    char    **pt_users;
  993. X    struct    pt_time    *pt_times;
  994. X};
  995. X
  996. X/*
  997. X *    t_days - bit array for each day of the week (0 = Sunday)
  998. X *    t_start - starting time for this entry
  999. X *    t_end - ending time for this entry
  1000. X */
  1001. X
  1002. Xstruct    pt_time    {
  1003. X    short    t_days;
  1004. X    short    t_start;
  1005. X    short    t_end;
  1006. X};
  1007. END_OF_FILE
  1008.   if test 1743 -ne `wc -c <'port.h'`; then
  1009.     echo shar: \"'port.h'\" unpacked with wrong size!
  1010.   fi
  1011.   # end of 'port.h'
  1012. fi
  1013. if test -f 'porttime.4' -a "${1}" != "-c" ; then 
  1014.   echo shar: Will not clobber existing file \"'porttime.4'\"
  1015. else
  1016.   echo shar: Extracting \"'porttime.4'\" \(1872 characters\)
  1017.   sed "s/^X//" >'porttime.4' <<'END_OF_FILE'
  1018. X.\" Copyright 1989, 1990, John F. Haugh II
  1019. X.\" All rights reserved.
  1020. X.\"
  1021. X.\" Use, duplication, and disclosure prohibited without
  1022. X.\" the express written permission of the author.
  1023. X.\"
  1024. X.\"    @(#)porttime.4    3.2    08:36:07    2/8/91
  1025. X.\"
  1026. X.TH PORTTIME 4
  1027. X.SH NAME
  1028. Xporttime \- port access time file
  1029. X.SH DESCRIPTION
  1030. X.I porttime
  1031. Xcontains a list of tty devices, user names, and permitted login times.
  1032. X.PP
  1033. XEach entry consists of three colon separated fields.
  1034. XThe first field is a comma separated list of tty devices,
  1035. Xor an asterisk to indicate that all tty devices are matched by this entry.
  1036. XThe second field is a comma separated list of user names, or an
  1037. Xasterisk to indicated that all user names are matched by this entry.
  1038. XThe third field is a comma separated list of permitted access times.
  1039. X.PP
  1040. XEach access time entry consists of zero or more days of the week,
  1041. Xabbreviated \fBSu\fR, \fBMo\fR, \fBTu\fR, \fBWe\fR, \fBTh\fR,
  1042. X\fBFr\fR, and \fBSa\fR, followed by a pair of times separated by
  1043. Xa hyphen.
  1044. XThe abbreviation \fBWk\fR may be used to represent Monday thru Friday,
  1045. Xand \fBAl\fR may be used to indicate every day.
  1046. XIf no days are given, \fBAl\fR is assumed.
  1047. X.SH Examples
  1048. XThe following entry allows access to user \fBjfh\fR on every port
  1049. Xduring weekdays from 9am to 5pm.
  1050. X.br
  1051. X.sp 1
  1052. X*:jfh:Wk0900-1700
  1053. X.br
  1054. X.sp 1
  1055. XThe following entries allow access only to the users \fBroot\fR and
  1056. X\fBoper\fR on /dev/console at any time.
  1057. XThis illustrates how the
  1058. X\fB/etc/porttime\fR file is an ordered list of access times.
  1059. XAny other user would match the second entry which does not permit
  1060. Xaccess at any time.
  1061. X.br
  1062. X.sp 1
  1063. Xconsole:root,oper:Al0000-2400
  1064. X.br
  1065. Xconsole:*:
  1066. X.br
  1067. X.sp 1
  1068. XThe following entry allows access for the user \fBgames\fR on any
  1069. Xport during non-working hours.
  1070. X.br
  1071. X.sp 1
  1072. X*:games:Wk1700-0900,SaSu0000-2400
  1073. X.br
  1074. X.sp 1
  1075. X.SH Files
  1076. X/etc/porttime \- file containing port access times
  1077. X.SH See Also
  1078. Xlogin(1)
  1079. END_OF_FILE
  1080.   if test 1872 -ne `wc -c <'porttime.4'`; then
  1081.     echo shar: \"'porttime.4'\" unpacked with wrong size!
  1082.   fi
  1083.   # end of 'porttime.4'
  1084. fi
  1085. if test -f 'pwd.h.m4' -a "${1}" != "-c" ; then 
  1086.   echo shar: Will not clobber existing file \"'pwd.h.m4'\"
  1087. else
  1088.   echo shar: Extracting \"'pwd.h.m4'\" \(2347 characters\)
  1089.   sed "s/^X//" >'pwd.h.m4' <<'END_OF_FILE'
  1090. X/*
  1091. X * Copyright 1990, 1991, John F. Haugh II and Steve Simmons
  1092. X * All rights reserved.
  1093. X *
  1094. X * Permission is granted to copy and create derivative works for any
  1095. X * non-commercial purpose, provided this copyright notice is preserved
  1096. X * in all copies of source code, or included in human readable form
  1097. X * and conspicuously displayed on all copies of object code or
  1098. X * distribution media.
  1099. X */
  1100. X
  1101. X/*
  1102. X * Standard definitions for password files.  This is an independant
  1103. X * reimplementation of the definitions used by AT&T, BSD, and POSIX.
  1104. X * It is not derived from any of those sources.  Note that it can be
  1105. X * site-defined to have non-POSIX features as well.
  1106. X *
  1107. X *    @(#)pwd.h.m4    3.1    08:54:41    11/3/91
  1108. X */
  1109. X
  1110. X#ifndef    PWD_H
  1111. X#define    PWD_H
  1112. X
  1113. X#ifdef    M_XENIX
  1114. Xtypedef int uid_t;
  1115. Xtypedef int gid_t;
  1116. X#endif
  1117. X
  1118. X#ifdef    SUN
  1119. X#include <sys/types.h>
  1120. X#endif
  1121. X
  1122. Xifdef(`SUN', `#define    BSD_QUOTAS')
  1123. Xifdef(`BSD', `#define    BSD_QUOTAS')
  1124. Xifdef(`USG', `#define    ATT_AGE')
  1125. Xifdef(`USG', `#define    ATT_COMMENT')
  1126. X
  1127. X/*
  1128. X * This is the data structure returned by the getpw* functions.  The
  1129. X * names of the elements and the structure are taken from traditional
  1130. X * usage.
  1131. X */
  1132. X
  1133. Xstruct passwd    {
  1134. X    char    *pw_name ;    /* User login name */
  1135. X    char    *pw_passwd ;    /* Encrypted passwd or dummy field */
  1136. X    uid_t    pw_uid ;    /* User uid number */
  1137. X    gid_t    pw_gid ;    /* User group id number */
  1138. X#ifdef    BSD_QUOTAS
  1139. X    /* Most BSD systems have quotas, most USG ones don't    */
  1140. X    int    pw_quota ;    /* The BSD magic doodah */
  1141. X#endif
  1142. X#ifdef    ATT_AGE
  1143. X    /* Use ATT-style password aging    */
  1144. X    char    *pw_age ;    /* ATT radix-64 encoded data */
  1145. X#endif
  1146. X#ifdef    ATT_COMMENT
  1147. X    /* Provide the unused comment field */
  1148. X    char    *pw_comment;    /* Unused comment field */
  1149. X#endif
  1150. X    char    *pw_gecos ;    /* ASCII user name, other data */
  1151. X    char    *pw_dir ;    /* User home directory */
  1152. X    char    *pw_shell ;    /* User startup shell */
  1153. X} ;
  1154. X
  1155. X#ifdef    ATT_COMMENT
  1156. X/* Provide the unused comment structure */
  1157. Xstruct comment {
  1158. X    char    *c_dept;
  1159. X    char    *c_name;
  1160. X    char    *c_acct;
  1161. X    char    *c_bin;
  1162. X};
  1163. X#endif
  1164. X
  1165. X#if    __STDC__
  1166. X
  1167. Xextern    struct    passwd    *getpwent( void ) ;
  1168. Xextern    struct    passwd    *getpwuid( uid_t user_uid ) ;
  1169. Xextern    struct    passwd    *getpwnam( char *name ) ;
  1170. Xint    setpwent( void );
  1171. Xint    endpwent( void );
  1172. X
  1173. X#else
  1174. X
  1175. Xextern    struct    passwd    *getpwent();
  1176. Xextern    struct    passwd    *getpwuid();
  1177. Xextern    struct    passwd    *getpwnam();
  1178. Xint    setpwent();
  1179. Xint    endpwent();
  1180. X
  1181. X#endif    /* of if __STDC__ */
  1182. X
  1183. X#endif    /* of ifdef PWD_H */
  1184. END_OF_FILE
  1185.   if test 2347 -ne `wc -c <'pwd.h.m4'`; then
  1186.     echo shar: \"'pwd.h.m4'\" unpacked with wrong size!
  1187.   fi
  1188.   # end of 'pwd.h.m4'
  1189. fi
  1190. if test -f 'rad64.c' -a "${1}" != "-c" ; then 
  1191.   echo shar: Will not clobber existing file \"'rad64.c'\"
  1192. else
  1193.   echo shar: Extracting \"'rad64.c'\" \(1670 characters\)
  1194.   sed "s/^X//" >'rad64.c' <<'END_OF_FILE'
  1195. X/*
  1196. X * Copyright 1989, 1990, John F. Haugh II
  1197. X * All rights reserved.
  1198. X *
  1199. X * Permission is granted to copy and create derivative works for any
  1200. X * non-commercial purpose, provided this copyright notice is preserved
  1201. X * in all copies of source code, or included in human readable form
  1202. X * and conspicuously displayed on all copies of object code or
  1203. X * distribution media.
  1204. X */
  1205. X
  1206. X#ifndef    lint
  1207. Xstatic    char    sccsid[] = "@(#)rad64.c    3.2    19:44:25    12/10/90";
  1208. X#endif
  1209. X
  1210. X/*
  1211. X * c64i - convert a radix 64 character to an integer
  1212. X */
  1213. X
  1214. Xint    c64i (c)
  1215. Xchar    c;
  1216. X{
  1217. X    if (c == '.')
  1218. X        return (0);
  1219. X
  1220. X    if (c == '/')
  1221. X        return (1);
  1222. X
  1223. X    if (c >= '0' && c <= '9')
  1224. X        return (c - '0' + 2);
  1225. X
  1226. X    if (c >= 'A' && c <= 'Z')
  1227. X        return (c - 'A' + 12);
  1228. X
  1229. X    if (c >= 'a' && c <= 'z')
  1230. X        return (c - 'a' + 38);
  1231. X    else
  1232. X        return (-1);
  1233. X}
  1234. X
  1235. X/*
  1236. X * i64c - convert an integer to a radix 64 character
  1237. X */
  1238. X
  1239. Xint    i64c (i)
  1240. Xint    i;
  1241. X{
  1242. X    if (i < 0)
  1243. X        return ('.');
  1244. X    else if (i > 63)
  1245. X        return ('z');
  1246. X
  1247. X    if (i == 0)
  1248. X        return ('.');
  1249. X
  1250. X    if (i == 1)
  1251. X        return ('/');
  1252. X
  1253. X    if (i >= 2 && i <= 11)
  1254. X        return ('0' - 2 + i);
  1255. X
  1256. X    if (i >= 12 && i <= 37)
  1257. X        return ('A' - 12 + i);
  1258. X
  1259. X    if (i >= 38 && i <= 63)
  1260. X        return ('a' - 38 + i);
  1261. X
  1262. X    return ('\0');
  1263. X}
  1264. X
  1265. X/*
  1266. X * l64a - convert a long to a string of radix 64 characters
  1267. X */
  1268. X
  1269. Xchar    *l64a (l)
  1270. Xlong    l;
  1271. X{
  1272. X    static    char    buf[8];
  1273. X    int    i = 0;
  1274. X
  1275. X    if (i < 0L)
  1276. X        return ((char *) 0);
  1277. X
  1278. X    do {
  1279. X        buf[i++] = i64c ((int) (l % 64));
  1280. X        buf[i] = '\0';
  1281. X    } while (l /= 64L, l > 0 && i < 6);
  1282. X
  1283. X    return (buf);
  1284. X}
  1285. X
  1286. X/*
  1287. X * a64l - convert a radix 64 string to a long integer
  1288. X */
  1289. X
  1290. Xlong    a64l (s)
  1291. Xchar    *s;
  1292. X{
  1293. X    int    i;
  1294. X    long    value;
  1295. X    long    shift = 0;
  1296. X
  1297. X    for (i = 0, value = 0L;i < 6 && *s;s++) {
  1298. X        value += (c64i (*s) << shift);
  1299. X        shift += 6;
  1300. X    }
  1301. X    return (value);
  1302. X}
  1303. END_OF_FILE
  1304.   if test 1670 -ne `wc -c <'rad64.c'`; then
  1305.     echo shar: \"'rad64.c'\" unpacked with wrong size!
  1306.   fi
  1307.   # end of 'rad64.c'
  1308. fi
  1309. if test -f 'shadow.4' -a "${1}" != "-c" ; then 
  1310.   echo shar: Will not clobber existing file \"'shadow.4'\"
  1311. else
  1312.   echo shar: Extracting \"'shadow.4'\" \(2122 characters\)
  1313.   sed "s/^X//" >'shadow.4' <<'END_OF_FILE'
  1314. X.\" Copyright 1989, 1990, John F. Haugh II
  1315. X.\" All rights reserved.
  1316. X.\"
  1317. X.\" Use, duplication, and disclosure prohibited without
  1318. X.\" the express written permission of the author.
  1319. X.\"
  1320. X.\"    @(#)shadow.4    3.1    23:49:44    11/11/90
  1321. X.\"
  1322. X.TH SHADOW 4
  1323. X.SH NAME
  1324. Xshadow \- encrypted password file
  1325. X.SH DESCRIPTION
  1326. X.I shadow
  1327. Xcontains the encrypted password information for user's accounts
  1328. Xand optional the password aging information.
  1329. XIncluded is
  1330. X.IP "" .5i
  1331. XLogin name
  1332. X.IP "" .5i
  1333. XEncrypted password
  1334. X.IP "" .5i
  1335. XDays since Jan 1, 1970 that password was last changed
  1336. X.IP "" .5i
  1337. XDays before password may be changed
  1338. X.IP "" .5i
  1339. XDays after which password must be changed
  1340. X.IP "" .5i
  1341. XDays before password is to expire that user is warned
  1342. X.IP "" .5i
  1343. XDays after password expires that account is disabled
  1344. X.IP "" .5i
  1345. XDays since Jan 1, 1970 that account is disabled
  1346. X.IP "" .5i
  1347. XA reserved field
  1348. X.PP
  1349. XThe password field must be filled.
  1350. XThe encryped password consists of 13 to 24 characters from the
  1351. X64 character alphabet
  1352. Xa thru z, A thru Z, 0 thru 9, \. and /.
  1353. XRefer to \fIcrypt(3)\fR for details on how this string is
  1354. Xinterpreted.
  1355. X.PP
  1356. XThe date of the last password change is given as the number
  1357. Xof days since Jan 1, 1970.
  1358. XThe password may not be changed again until the proper number
  1359. Xof days have passed, and must be changed after the maximum
  1360. Xnumber of days.
  1361. XIf the minimum number of days required is greater than the
  1362. Xmaximum number of day allowed, this password may not be
  1363. Xchanged by the user.
  1364. X.PP
  1365. XAn account is considered to be inactive and is disabled if
  1366. Xthe password is not changed within the specified number of
  1367. Xdays after the password expires.
  1368. XAn account will also be disabled on the specified day
  1369. Xregardless of other password expiration information.
  1370. X.PP
  1371. XThis information supercedes any password or password age
  1372. Xinformation present in \fB/etc/passwd\fR.
  1373. X.PP
  1374. XThis file must not be readable by regular users if password
  1375. Xsecurity is to be maintained.
  1376. X.SH Files
  1377. X/etc/passwd \- user account information
  1378. X.br
  1379. X/etc/shadow \- encrypted user passwords
  1380. X.SH See Also
  1381. Xchage(1),
  1382. Xlogin(1),
  1383. Xpasswd(1),
  1384. Xsu(1),
  1385. Xsulogin(1M),
  1386. Xshadow(3),
  1387. Xpasswd(4),
  1388. Xpwconv(8),
  1389. Xpwunconv(8)
  1390. END_OF_FILE
  1391.   if test 2122 -ne `wc -c <'shadow.4'`; then
  1392.     echo shar: \"'shadow.4'\" unpacked with wrong size!
  1393.   fi
  1394.   # end of 'shadow.4'
  1395. fi
  1396. if test -f 'shadow.h' -a "${1}" != "-c" ; then 
  1397.   echo shar: Will not clobber existing file \"'shadow.h'\"
  1398. else
  1399.   echo shar: Extracting \"'shadow.h'\" \(1823 characters\)
  1400.   sed "s/^X//" >'shadow.h' <<'END_OF_FILE'
  1401. X/*
  1402. X * Copyright 1988, 1989, 1990, John F. Haugh II
  1403. X * All rights reserved.
  1404. X *
  1405. X * Use, duplication, and disclosure prohibited without
  1406. X * the express written permission of the author.
  1407. X */
  1408. X
  1409. X#ifndef    _H_SHADOW
  1410. X#define    _H_SHADOW
  1411. X
  1412. X/*
  1413. X * This information is not derived from AT&T licensed sources.  Posted
  1414. X * to the USENET 11/88, and updated 11/90 with information from SVR4.
  1415. X *
  1416. X *    @(#)shadow.h    3.3    09:06:50    12/7/90
  1417. X */
  1418. X
  1419. X#ifdef    ITI_AGING
  1420. Xtypedef    time_t    sptime;
  1421. X#else
  1422. Xtypedef    long    sptime;
  1423. X#endif
  1424. X
  1425. X/*
  1426. X * Shadow password security file structure.
  1427. X */
  1428. X
  1429. Xstruct    spwd {
  1430. X    char    *sp_namp;    /* login name */
  1431. X    char    *sp_pwdp;    /* encrypted password */
  1432. X    sptime    sp_lstchg;    /* date of last change */
  1433. X    sptime    sp_min;        /* minimum number of days between changes */
  1434. X    sptime    sp_max;        /* maximum number of days between changes */
  1435. X    sptime    sp_warn;    /* number of days of warning before password
  1436. X                   expires */
  1437. X    sptime    sp_inact;    /* number of days after password expires
  1438. X                   until the account becomes unusable. */
  1439. X    sptime    sp_expire;    /* days since 1/1/70 until account expires */
  1440. X    unsigned long    sp_flag; /* reserved for future use */
  1441. X};
  1442. X
  1443. X/*
  1444. X * Shadow password security file functions.
  1445. X */
  1446. X
  1447. Xstruct    spwd    *getspent ();
  1448. Xstruct    spwd    *getspnam ();
  1449. Xstruct    spwd    *sgetspent ();
  1450. Xstruct    spwd    *fgetspent ();
  1451. Xvoid    setspent ();
  1452. Xvoid    endspent ();
  1453. Xint    putspent ();
  1454. X
  1455. X#define  SHADOW "/etc/shadow"
  1456. X
  1457. X/*
  1458. X * Shadow group security file structure
  1459. X */
  1460. X
  1461. Xstruct    sgrp {
  1462. X    char    *sg_name;    /* group name */
  1463. X    char    *sg_passwd;    /* group password */
  1464. X    char    **sg_adm;    /* group administator list */
  1465. X    char    **sg_mem;    /* group membership list */
  1466. X};
  1467. X
  1468. X/*
  1469. X * Shadow group security file functions.
  1470. X */
  1471. X
  1472. Xstruct    sgrp    *getsgent ();
  1473. Xstruct    sgrp    *getsgnam ();
  1474. Xstruct    sgrp    *sgetsgent ();
  1475. Xstruct    sgrp    *fgetsgent ();
  1476. Xvoid    setsgent ();
  1477. Xvoid    endsgent ();
  1478. Xint    putsgent ();
  1479. X
  1480. X#define    GSHADOW    "/etc/gshadow"
  1481. X#endif
  1482. END_OF_FILE
  1483.   if test 1823 -ne `wc -c <'shadow.h'`; then
  1484.     echo shar: \"'shadow.h'\" unpacked with wrong size!
  1485.   fi
  1486.   # end of 'shadow.h'
  1487. fi
  1488. if test -f 'sppack.c' -a "${1}" != "-c" ; then 
  1489.   echo shar: Will not clobber existing file \"'sppack.c'\"
  1490. else
  1491.   echo shar: Extracting \"'sppack.c'\" \(2186 characters\)
  1492.   sed "s/^X//" >'sppack.c' <<'END_OF_FILE'
  1493. X/*
  1494. X * Copyright 1990, 1991, John F. Haugh II
  1495. X * All rights reserved.
  1496. X *
  1497. X * Permission is granted to copy and create derivative works for any
  1498. X * non-commercial purpose, provided this copyright notice is preserved
  1499. X * in all copies of source code, or included in human readable form
  1500. X * and conspicuously displayed on all copies of object code or
  1501. X * distribution media.
  1502. X */
  1503. X
  1504. X#include <stdio.h>
  1505. X#ifdef    BSD
  1506. X#include <strings.h>
  1507. X#else
  1508. X#include <string.h>
  1509. X#endif
  1510. X
  1511. X#include "shadow.h"
  1512. X
  1513. X#ifndef    lint
  1514. Xstatic    char    sccsid[] = "@(#)sppack.c    3.2    08:46:24    9/12/91";
  1515. X#endif
  1516. X
  1517. Xint    spw_pack (spwd, buf)
  1518. Xstruct    spwd    *spwd;
  1519. Xchar    *buf;
  1520. X{
  1521. X    char    *cp;
  1522. X
  1523. X    cp = buf;
  1524. X    strcpy (cp, spwd->sp_namp);
  1525. X    cp += strlen (cp) + 1;
  1526. X
  1527. X    strcpy (cp, spwd->sp_pwdp);
  1528. X    cp += strlen (cp) + 1;
  1529. X
  1530. X    memcpy (cp, &spwd->sp_min, sizeof spwd->sp_min);
  1531. X    cp += sizeof spwd->sp_min;
  1532. X
  1533. X    memcpy (cp, &spwd->sp_max, sizeof spwd->sp_max);
  1534. X    cp += sizeof spwd->sp_max;
  1535. X
  1536. X    memcpy (cp, &spwd->sp_lstchg, sizeof spwd->sp_lstchg);
  1537. X    cp += sizeof spwd->sp_lstchg;
  1538. X
  1539. X    memcpy (cp, &spwd->sp_warn, sizeof spwd->sp_warn);
  1540. X    cp += sizeof spwd->sp_warn;
  1541. X
  1542. X    memcpy (cp, &spwd->sp_inact, sizeof spwd->sp_inact);
  1543. X    cp += sizeof spwd->sp_inact;
  1544. X
  1545. X    memcpy (cp, &spwd->sp_expire, sizeof spwd->sp_expire);
  1546. X    cp += sizeof spwd->sp_expire;
  1547. X
  1548. X    memcpy (cp, &spwd->sp_flag, sizeof spwd->sp_flag);
  1549. X    cp += sizeof spwd->sp_flag;
  1550. X
  1551. X    return cp - buf;
  1552. X}
  1553. X
  1554. Xint    spw_unpack (buf, len, spwd)
  1555. Xchar    *buf;
  1556. Xint    len;
  1557. Xstruct    spwd    *spwd;
  1558. X{
  1559. X    char    *org = buf;
  1560. X
  1561. X    spwd->sp_namp = buf;
  1562. X    buf += strlen (buf) + 1;
  1563. X
  1564. X    spwd->sp_pwdp = buf;
  1565. X    buf += strlen (buf) + 1;
  1566. X
  1567. X    memcpy (&spwd->sp_min, buf, sizeof spwd->sp_min);
  1568. X    buf += sizeof spwd->sp_min;
  1569. X
  1570. X    memcpy (&spwd->sp_max, buf, sizeof spwd->sp_max);
  1571. X    buf += sizeof spwd->sp_max;
  1572. X
  1573. X    memcpy (&spwd->sp_lstchg, buf, sizeof spwd->sp_lstchg);
  1574. X    buf += sizeof spwd->sp_lstchg;
  1575. X
  1576. X    memcpy (&spwd->sp_warn, buf, sizeof spwd->sp_warn);
  1577. X    buf += sizeof spwd->sp_warn;
  1578. X
  1579. X    memcpy (&spwd->sp_inact, buf, sizeof spwd->sp_inact);
  1580. X    buf += sizeof spwd->sp_inact;
  1581. X
  1582. X    memcpy (&spwd->sp_expire, buf, sizeof spwd->sp_expire);
  1583. X    buf += sizeof spwd->sp_expire;
  1584. X
  1585. X    memcpy (&spwd->sp_flag, buf, sizeof spwd->sp_flag);
  1586. X    buf += sizeof spwd->sp_flag;
  1587. X
  1588. X    if (buf - org > len)
  1589. X        return -1;
  1590. X
  1591. X    return 0;
  1592. X}
  1593. END_OF_FILE
  1594.   if test 2186 -ne `wc -c <'sppack.c'`; then
  1595.     echo shar: \"'sppack.c'\" unpacked with wrong size!
  1596.   fi
  1597.   # end of 'sppack.c'
  1598. fi
  1599. if test -f 'su.1' -a "${1}" != "-c" ; then 
  1600.   echo shar: Will not clobber existing file \"'su.1'\"
  1601. else
  1602.   echo shar: Extracting \"'su.1'\" \(1697 characters\)
  1603.   sed "s/^X//" >'su.1' <<'END_OF_FILE'
  1604. X.\" Copyright 1989, 1990, John F. Haugh II
  1605. X.\" All rights reserved.
  1606. X.\"
  1607. X.\" Use, duplication, and disclosure prohibited without
  1608. X.\" the express written permission of the author.
  1609. X.\"
  1610. X.\"    @(#)su.1    3.1    09:34:28    11/21/90
  1611. X.\"
  1612. X.TH SU 1
  1613. X.SH NAME
  1614. Xsu \- Change user ID or become super-user
  1615. X.SH SYNOPSIS
  1616. X.B su
  1617. X[ - ] [ username [ args ] ]
  1618. X.SH DESCRIPTION
  1619. X.I su
  1620. Xis used to become another user during a login session.
  1621. XInvoked without a username, \fIsu\fR defaults to becoming
  1622. Xthe super user.
  1623. XThe optional argument \fB\-\fR may be used to provide an
  1624. Xenvironment similiar to what the user would expect had
  1625. Xthe user logged in directly.
  1626. X.PP
  1627. XAdditional arguments may be provided after the username,
  1628. Xin which case they are supplied to the user\'s login shell.
  1629. XIn particular, an argument of \fB-c\fR will cause the
  1630. Xnext argument to be treated as a command by most command
  1631. Xinterpreters.
  1632. XThe command will be executed under the shell specified by
  1633. X\fB$SHELL\fR, or if undefined, by the one specified in
  1634. X\fI/etc/passwd\fR.
  1635. X.PP
  1636. XThe user will be prompted for a password, if appropriate.
  1637. XInvalid passwords will produce an error message.
  1638. XAll attempts, both valid and invalid, are logged to detect
  1639. Xabuses of the system.
  1640. X.PP
  1641. XThe current environment is passed to the new shell.
  1642. XThe value of \fB$PATH\fR is reset to \fB/bin:/usr/bin\fR
  1643. Xfor normal users, or \fB/bin:/usr/bin:/etc\fR for the super user.
  1644. X.SH CAVEATS
  1645. X.PP
  1646. XThis version of \fIsu\fR has many compilation options, only some of which
  1647. Xmay be in use at any particular site.
  1648. X.SH Files
  1649. X/etc/passwd \- user account information
  1650. X.br
  1651. X/etc/shadow \- encrypted passwords and age information
  1652. X.br
  1653. X$HOME/.profile \- initialization script for default shell
  1654. X.SH See Also
  1655. Xlogin(1),
  1656. Xsh(1)
  1657. END_OF_FILE
  1658.   if test 1697 -ne `wc -c <'su.1'`; then
  1659.     echo shar: \"'su.1'\" unpacked with wrong size!
  1660.   fi
  1661.   # end of 'su.1'
  1662. fi
  1663. if test -f 'sub.c' -a "${1}" != "-c" ; then 
  1664.   echo shar: Will not clobber existing file \"'sub.c'\"
  1665. else
  1666.   echo shar: Extracting \"'sub.c'\" \(1724 characters\)
  1667.   sed "s/^X//" >'sub.c' <<'END_OF_FILE'
  1668. X/*
  1669. X * Copyright 1989, 1990, 1991, John F. Haugh II
  1670. X * All rights reserved.
  1671. X *
  1672. X * Permission is granted to copy and create derivative works for any
  1673. X * non-commercial purpose, provided this copyright notice is preserved
  1674. X * in all copies of source code, or included in human readable form
  1675. X * and conspicuously displayed on all copies of object code or
  1676. X * distribution media.
  1677. X */
  1678. X
  1679. X#include <sys/types.h>
  1680. X#include "config.h"
  1681. X
  1682. X#ifdef    USE_SYSLOG
  1683. X#include <syslog.h>
  1684. X
  1685. X#ifndef    LOG_WARN
  1686. X#define    LOG_WARN    LOG_WARNING
  1687. X#endif
  1688. X#endif
  1689. X
  1690. X#include "pwd.h"
  1691. X
  1692. X#ifndef    lint
  1693. Xstatic    char    sccsid[] = "@(#)sub.c    3.3    09:08:19    5/28/91";
  1694. X#endif
  1695. X
  1696. X#define    BAD_SUBROOT    "Invalid root directory \"%s\"\n"
  1697. X#define    BAD_SUBROOT2    "invalid root `%s' for user `%s'\n"
  1698. X#define    NO_SUBROOT    "Can't change root directory to \"%s\"\n"
  1699. X#define    NO_SUBROOT2    "no subsystem root `%s' for user `%s'\n"
  1700. X
  1701. X/*
  1702. X * subsystem - change to subsystem root
  1703. X *
  1704. X *    A subsystem login is indicated by the presense of a "*" as
  1705. X *    the first character of the login shell.  The given home
  1706. X *    directory will be used as the root of a new filesystem which
  1707. X *    the user is actually logged into.
  1708. X */
  1709. X
  1710. Xvoid    subsystem (pw)
  1711. Xstruct    passwd    *pw;
  1712. X{
  1713. X    /*
  1714. X     * The new root directory must begin with a "/" character.
  1715. X     */
  1716. X
  1717. X    if (pw->pw_dir[0] != '/') {
  1718. X        printf (BAD_SUBROOT, pw->pw_dir);
  1719. X#ifdef    USE_SYSLOG
  1720. X        syslog (LOG_WARN, BAD_SUBROOT2, pw->pw_dir, pw->pw_name);
  1721. X        closelog ();
  1722. X#endif
  1723. X        exit (1);
  1724. X    }
  1725. X
  1726. X    /*
  1727. X     * The directory must be accessible and the current process
  1728. X     * must be able to change into it.
  1729. X     */
  1730. X
  1731. X    if (chdir (pw->pw_dir) || chroot (pw->pw_dir)) {
  1732. X        printf (NO_SUBROOT, pw->pw_dir);
  1733. X#ifdef    USE_SYSLOG
  1734. X        syslog (LOG_WARN, NO_SUBROOT2, pw->pw_dir, pw->pw_name);
  1735. X        closelog ();
  1736. X#endif
  1737. X        exit (1);
  1738. X    }
  1739. X}
  1740. END_OF_FILE
  1741.   if test 1724 -ne `wc -c <'sub.c'`; then
  1742.     echo shar: \"'sub.c'\" unpacked with wrong size!
  1743.   fi
  1744.   # end of 'sub.c'
  1745. fi
  1746. if test -f 'sulogin.8' -a "${1}" != "-c" ; then 
  1747.   echo shar: Will not clobber existing file \"'sulogin.8'\"
  1748. else
  1749.   echo shar: Extracting \"'sulogin.8'\" \(1769 characters\)
  1750.   sed "s/^X//" >'sulogin.8' <<'END_OF_FILE'
  1751. X.\" Copyright 1989, 1990, John F. Haugh II
  1752. X.\" All rights reserved.
  1753. X.\"
  1754. X.\" Use, duplication, and disclosure prohibited without
  1755. X.\" the express written permission of the author.
  1756. X.\"
  1757. X.\"    @(#)sulogin.8    3.2    07:50:00    7/13/91
  1758. X.\"
  1759. X.TH SULOGIN 8
  1760. X.SH NAME
  1761. Xsulogin \- Single-user login
  1762. X.SH DESCRIPTION
  1763. X.I sulogin
  1764. Xis invoked by \fB/etc/init\fR prior to allowing the user
  1765. Xaccess to the system when in single user mode.
  1766. XThis feature may only be available on certain systems where
  1767. X\fIinit\fR has been modified accordingly, or where the
  1768. X\fB/etc/inittab\fR has an entry for a single user login.
  1769. X.PP
  1770. XThe user is prompted
  1771. X.IP "" .5i
  1772. XType control-d for normal startup,
  1773. X.br
  1774. X(or give root password for system maintenance):
  1775. X.PP
  1776. XIf the user enters the correct root password, a login session
  1777. Xis initiated.
  1778. XWhen \fBEOF\fR is pressed instead, the system enters multi-user
  1779. Xmode.
  1780. X.PP
  1781. XAfter the user exits the single-user shell, or presses \fBEOF\fR,
  1782. Xthe system begins the initialization process required to enter
  1783. Xmulti-user mode.
  1784. X.SH CAVEATS
  1785. X.PP
  1786. XThis command can only be used if \fIinit\fR has been modified to call
  1787. X\fB/etc/sulogin\fR instead of \fB/bin/sh\fR,
  1788. Xor if the user has set the \fIinittab\fR to support a single user
  1789. Xlogin.
  1790. XFor example, the line
  1791. X.br
  1792. X.sp 1
  1793. Xco:s:respawn:/etc/sulogin < /dev/console > /dev/console 2>&1
  1794. X.br
  1795. X.sp 1
  1796. Xshould execute the sulogin command in single user mode.
  1797. X.PP
  1798. XAs complete an environment as possible is created.
  1799. XHowever, various devices may be unmounted or uninitialized and many 
  1800. Xof the user commands may be unavailable or nonfunctional as a result.
  1801. X.SH Files
  1802. X/etc/passwd \- user account information
  1803. X.br
  1804. X/etc/shadow \- encrypted passwords and age information
  1805. X.br
  1806. X/.profile \- initialization script for single user shell
  1807. X.SH See Also
  1808. Xlogin(1),
  1809. Xinit(1M),
  1810. Xsh(1)
  1811. END_OF_FILE
  1812.   if test 1769 -ne `wc -c <'sulogin.8'`; then
  1813.     echo shar: \"'sulogin.8'\" unpacked with wrong size!
  1814.   fi
  1815.   # end of 'sulogin.8'
  1816. fi
  1817. if test -f 'ttytype.c' -a "${1}" != "-c" ; then 
  1818.   echo shar: Will not clobber existing file \"'ttytype.c'\"
  1819. else
  1820.   echo shar: Extracting \"'ttytype.c'\" \(1691 characters\)
  1821.   sed "s/^X//" >'ttytype.c' <<'END_OF_FILE'
  1822. X/*
  1823. X * Copyright 1989, 1990, 1991, John F. Haugh II
  1824. X * All rights reserved.
  1825. X *
  1826. X * Permission is granted to copy and create derivative works for any
  1827. X * non-commercial purpose, provided this copyright notice is preserved
  1828. X * in all copies of source code, or included in human readable form
  1829. X * and conspicuously displayed on all copies of object code or
  1830. X * distribution media.
  1831. X */
  1832. X
  1833. X#include <stdio.h>
  1834. X#ifndef    BSD
  1835. X#include <string.h>
  1836. X#include <memory.h>
  1837. X#else
  1838. X#include <strings.h>
  1839. X#define    strchr    index
  1840. X#define    strrchr    rindex
  1841. X#endif
  1842. X#include "config.h"
  1843. X
  1844. X#ifndef    lint
  1845. Xstatic    char    _sccsid[] = "@(#)ttytype.c    3.1    07:43:33    9/17/91";
  1846. X#endif
  1847. X
  1848. Xextern    char    *getdef_str();
  1849. X
  1850. X/*
  1851. X * ttytype - set ttytype from port to terminal type mapping database
  1852. X */
  1853. X
  1854. Xvoid
  1855. Xttytype (line)
  1856. Xchar    *line;
  1857. X{
  1858. X    FILE    *fp;
  1859. X    char    buf[BUFSIZ];
  1860. X    char    termvar[BUFSIZ];
  1861. X    char    *ttytype;
  1862. X    char    *cp;
  1863. X    char    *type;
  1864. X    char    *port;
  1865. X    char    *getenv ();
  1866. X
  1867. X    if (getenv ("TERM"))
  1868. X        return;
  1869. X    if ((ttytype=getdef_str("TTYTYPE_FILE")) == NULL )
  1870. X        return;
  1871. X    if (access (ttytype, 0))
  1872. X        return;
  1873. X
  1874. X    if (! (fp = fopen (ttytype, "r"))) {
  1875. X        perror (ttytype);
  1876. X        return;
  1877. X    }
  1878. X    while (fgets (buf, BUFSIZ, fp)) {
  1879. X        if (buf[0] == '#')
  1880. X            continue;
  1881. X
  1882. X        if (cp = strchr (buf, '\n'))
  1883. X            *cp = '\0';
  1884. X
  1885. X#if defined(SUN) || defined(BSD)
  1886. X        if ((port = strtok (buf, "\t"))
  1887. X                && (type = strtok ((char *) 0, "\t"))
  1888. X                && (type = strtok ((char *) 0, "\t"))) {
  1889. X            if (strcmp (line, port) == 0)
  1890. X                break;
  1891. X        }    
  1892. X#else    /* USG */
  1893. X        if ((type = strtok (buf, " \t"))
  1894. X                && (port = strtok ((char *) 0, " \t"))) {
  1895. X            if (strcmp (line, port) == 0)
  1896. X                break;
  1897. X        }
  1898. X    }
  1899. X#endif
  1900. X    if (! feof (fp) && ! ferror (fp)) {
  1901. X        strcat (strcpy (termvar, "TERM="), type);
  1902. X        addenv (termvar);
  1903. X    }
  1904. X    fclose (fp);
  1905. X}
  1906. END_OF_FILE
  1907.   if test 1691 -ne `wc -c <'ttytype.c'`; then
  1908.     echo shar: \"'ttytype.c'\" unpacked with wrong size!
  1909.   fi
  1910.   # end of 'ttytype.c'
  1911. fi
  1912. if test -f 'valid.c' -a "${1}" != "-c" ; then 
  1913.   echo shar: Will not clobber existing file \"'valid.c'\"
  1914. else
  1915.   echo shar: Extracting \"'valid.c'\" \(2323 characters\)
  1916.   sed "s/^X//" >'valid.c' <<'END_OF_FILE'
  1917. X/*
  1918. X * Copyright 1989, 1990, 1991, John F. Haugh II
  1919. X * All rights reserved.
  1920. X *
  1921. X * Permission is granted to copy and create derivative works for any
  1922. X * non-commercial purpose, provided this copyright notice is preserved
  1923. X * in all copies of source code, or included in human readable form
  1924. X * and conspicuously displayed on all copies of object code or
  1925. X * distribution media.
  1926. X */
  1927. X
  1928. X#include <stdio.h>
  1929. X#include "pwd.h"
  1930. X#ifdef    BSD
  1931. X#include <strings.h>
  1932. X#define    strchr    index
  1933. X#define    strrchr    rindex
  1934. X#else
  1935. X#include <string.h>
  1936. X#include <memory.h>
  1937. X#endif
  1938. X#include "config.h"
  1939. X
  1940. X#ifndef    lint
  1941. Xstatic    char    _sccsid[] = "@(#)valid.c    3.4    08:44:15    9/12/91";
  1942. X#endif
  1943. X
  1944. X/*
  1945. X * valid - compare encrypted passwords
  1946. X *
  1947. X *    Valid() compares the DES encrypted password from the password file
  1948. X *    against the password which the user has entered after it has been
  1949. X *    encrypted using the same salt as the original.  Entries which do
  1950. X *    not have a password file entry have a NULL pw_name field and this
  1951. X *    is used to indicate that a dummy salt must be used to encrypt the
  1952. X *    password anyway.
  1953. X */
  1954. X
  1955. Xint    valid (password, entry)
  1956. Xchar    *password;
  1957. Xstruct    passwd    *entry;
  1958. X{
  1959. X    char    *encrypt;
  1960. X    char    *salt;
  1961. X    char    *pw_encrypt ();
  1962. X
  1963. X    /*
  1964. X     * Start with blank or empty password entries.  Always encrypt
  1965. X     * a password if no such user exists.  Only if the ID exists and
  1966. X     * the password is really empty do you return quickly.  This
  1967. X     * routine is meant to waste CPU time.
  1968. X     */
  1969. X
  1970. X    if (entry->pw_name && ! entry->pw_passwd[0]) {
  1971. X        if (! password[0])
  1972. X            return (1);    /* user entered nothing */
  1973. X        else
  1974. X            return (0);    /* user entered something! */
  1975. X    }
  1976. X
  1977. X    /*
  1978. X     * If there is no entry then we need a salt to use.
  1979. X     */
  1980. X
  1981. X    if (entry->pw_name == (char *) 0 || entry->pw_passwd[0] == '\0')
  1982. X        salt = "xx";
  1983. X    else
  1984. X        salt = entry->pw_passwd;
  1985. X
  1986. X    /*
  1987. X     * Now, perform the encryption using the salt from before on
  1988. X     * the users input.  Since we always encrypt the string, it
  1989. X     * should be very difficult to determine if the user exists by
  1990. X     * looking at execution time.
  1991. X     */
  1992. X
  1993. X    encrypt = pw_encrypt (password, salt);
  1994. X
  1995. X    /*
  1996. X     * One last time we must deal with there being no password file
  1997. X     * entry for the user.  We use the pw_passwd == NULL idiom to
  1998. X     * cause non-existent users to not be validated.
  1999. X     */
  2000. X
  2001. X    if (entry->pw_name && strcmp (encrypt, entry->pw_passwd) == 0)
  2002. X        return (1);
  2003. X    else
  2004. X        return (0);
  2005. X}
  2006. END_OF_FILE
  2007.   if test 2323 -ne `wc -c <'valid.c'`; then
  2008.     echo shar: \"'valid.c'\" unpacked with wrong size!
  2009.   fi
  2010.   # end of 'valid.c'
  2011. fi
  2012. echo shar: End of archive 10 \(of 11\).
  2013. cp /dev/null ark10isdone
  2014. MISSING=""
  2015. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  2016.     if test ! -f ark${I}isdone ; then
  2017.     MISSING="${MISSING} ${I}"
  2018.     fi
  2019. done
  2020. if test "${MISSING}" = "" ; then
  2021.     echo You have unpacked all 11 archives.
  2022.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2023. else
  2024.     echo You still must unpack the following archives:
  2025.     echo "        " ${MISSING}
  2026. fi
  2027. exit 0
  2028. exit 0 # Just in case...
  2029.